﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;


namespace WebLicenseGenerator
{
	public partial class WebLicenseMain : System.Web.UI.MasterPage
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			masterPageScriptManager.AsyncPostBackError += new EventHandler<AsyncPostBackErrorEventArgs>(masterPageScriptManager_AsyncPostBackError);
		}

		void masterPageScriptManager_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
		{
			StreamWriter sw = new StreamWriter(Server.MapPath("/log.txt"));
			sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + e.Exception.Message + "[" + e.Exception.InnerException + "]");
			sw.Close();
		}

		protected void lnk_Click(object sender, EventArgs e)
		{
			string lnkButtonID = ((LinkButton)sender).ID;

			switch (lnkButtonID)
			{
				case "lnkNewLicense":
					Response.Redirect("NewLicense.aspx");
					break;
				case "lnkSearchLicenses":
					Response.Redirect("SearchLicenses.aspx");
					break;
				case "lnkSearchHistory":
					Response.Redirect("SearchHistory.aspx");
					break;
				case "lnkManageCompanies":
					Response.Redirect("ManageCompanies.aspx");
					break;
				case "lnkManageAliases":
					Response.Redirect("ManageAliases.aspx");
					break;
			}
		}
	}
}